package com.wefans.wefansapp.activity;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wefans.wefansapp.R;
import com.wefans.wefansapp.common.tool.data.WinningData;

public class MywinningAdapter extends BaseAdapter {

	private ArrayList<WinningData> mWinningList = null;
    private LayoutInflater mInflater = null;
    private ViewHolder viewHolder = null;

	public MywinningAdapter(Context c, ArrayList<WinningData> winningList) {
		super();
		this.mInflater = LayoutInflater.from(c);
		this.mWinningList = winningList;
	}

	class ViewHolder {        
        public TextView tv_Name;
        public TextView tv_Desc;
    }

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mWinningList.size();
	}


	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mWinningList.get(position);
	}


	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}


	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
        
        if(v == null){
            viewHolder = new ViewHolder();
            v = mInflater.inflate(R.layout.list_item_winning, null);
            viewHolder.tv_Name = (TextView) v.findViewById(R.id.TV_WINNGIN_TITLE);
            viewHolder.tv_Desc = (TextView) v.findViewById(R.id.TV_WINNGIN_DATE);
            v.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder)v.getTag();
        }
        
        WinningData dtWin = (WinningData) getItem(position);
        
        if (dtWin != null) {
        	viewHolder.tv_Name.setText(dtWin.getName());
        	viewHolder.tv_Desc.setText(dtWin.getDesc());
        }
         
        return v;
	}


}
